package com.tang.algorithm.doublePointer;

/**
 * @author tlm
 * @Description
 * @date 2020/7/29 5:51 下午
 */
public class LeetCode27 {
	public static void main(String[] args) {
		LeetCode27 leetCode27 = new LeetCode27();
		int[] a = {0,1,2,2,3,0,4,2};
		System.out.println(leetCode27.removeElement(a, 2));
	}
	public int removeElement(int[] nums, int val) {
		int i = 0;
		for (int j = 0; j < nums.length; j++) {
			if (nums[j] != val) {
				nums[i] = nums[j];
				i++;
			}
		}
		return i;
	}

}
